﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.WindowsAzure.StorageClient;

namespace ToDoWebRole
{
    public class ToDoDataModel : TableServiceEntity
    {

        public ToDoDataModel(string partitionKey, string rowKey)
            : base(partitionKey, rowKey)
        {
            //Obviously, not generally a good pattern, but since we know pk is GUID...
            this.ID = partitionKey;
        }

        public ToDoDataModel(string name)
            : this()
        {
            this.DisplayName = name;
        }

        public ToDoDataModel()
            : this(Guid.NewGuid().ToString(), String.Empty)
        {
        }

        public string ID
        {
            get;
            set;
        }

        public string DisplayName { get; set; }
        public bool IsComplete { get; set; }
        public string Parent { get; set; }
        public string Predecessor { get; set; }

        internal void Add(ToDoDataModel t)
        {
            t.Parent = this.ID;
        }

        internal void Follows(ToDoDataModel td)
        {
            this.Predecessor = td.ID;
        }

        public readonly static string ROOT_ID = "_ROOT";
    }
}
